package me.sunpeng.design.prototype.deepclone;

/**
 * @author sp
 */
public class Client {
    public static void main(String[] args) throws CloneNotSupportedException {
        DeepProtoType deepProtoType1 = new DeepProtoType();
        deepProtoType1.name = "tom";
        deepProtoType1.deepCloneableTarget = new DeepCloneableTarget("deepCloneableTarget1",
                "DeepCloneableTarget1");

        //方式1 完成深拷贝
        DeepProtoType deepProtoType2 = (DeepProtoType) deepProtoType1.clone();

        System.out.println("deepProtoType1.name=" + deepProtoType1.name);
        System.out.println("deepProtoType1.deepCloneableTarget=" + deepProtoType1.deepCloneableTarget.hashCode());
        System.out.println("deepProtoType2.name=" + deepProtoType2.name);
        System.out.println("deepProtoType2.deepCloneableTarget=" + deepProtoType2.deepCloneableTarget.hashCode());

        //方式2 完成深拷贝
        DeepProtoType deepProtoType3 = (DeepProtoType) deepProtoType1.deepClone();
        System.out.println("deepProtoType1.name=" + deepProtoType1.name);
        System.out.println("deepProtoType3.deepCloneableTarget=" + deepProtoType1.deepCloneableTarget.hashCode());
        System.out.println("deepProtoType2.name=" + deepProtoType3.name);
        System.out.println("deepProtoType3.deepCloneableTarget=" + deepProtoType3.deepCloneableTarget.hashCode());


    }
}
